<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class PasswordModifyRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        if ($this->isMethod('post')) {
            return [
                'old_password' => 'required',
                'password' => 'required|confirmed',
            ]; 
        }

        return [];
    }

    public function messages()
    {
        return [
            'old_password.required' => '请输入原始密码',
            'password.required' => '新密码不能为空',
            'password.confirmed' => '两次密码不匹配',
        ];
    }
}
